<#assign pageName="系统机构管理">
<@override name="page-content">
<form class="layui-form form-horizontal" role="form" method="post">
    <div class="layui-form-search panel">
        <input type="text" hidden="hidden" name="_STATE"/>
        <@ctrl.TreeSelectQuery path="department.guid" dataList=guidsList![] fieldText="sysModuleName"  class=""
            fieldValue="guid" labelText="所属平台" fieldParentID="upperGuid" parentidValue="${(guids.upperGuid)!'-1'}" />
        <div class="margin-5">
            <a href="javascript:;" onclick="$('form:first').submit();" class="layui-btn layui-btn-sm">
                <i class="layui-icon layui-icon-search"></i>查询
            </a>
            <a href="javascript:;" class="layui-btn layui-btn-normal layui-btn-sm js-add">
                <i class="layui-icon layui-icon-add-1"></i>新增
            </a>
        </div>
    </div>
    <table class="layui-table">
        <thead>
            <tr>
                <th class="align-center" width="50px" nowrap="nowrap">序号</th>
                <th class="align-center" nowrap="nowrap">机构类型</th>
                <th class="align-center" nowrap="nowrap">机构编码</th>
                <th class="align-center" nowrap="nowrap">机构名称</th>
                <th class="align-center layui-hide-xs">负责人</th>
                <th class="align-center layui-hide-xs">手机号码</th>
                <th class="align-center layui-hide-xs">联系电话</th>
                <th class="align-center layui-hide-xs">详细地址</th>
                <th class="align-center layui-hide-xs" nowrap="nowrap">状态</th>
                <th class="align-center" width="120px">操作</th>
            </tr>
        </thead>
        <tbody>
            <@ctrl.Recursive dataList=depList fieldID='depId' fieldParentID='upperId' 
                parentidValue=(dep.upperId)!'-1';dataItem,level,separator,dataIndex>
            <tr>
                <td class="align-center" width="50px" nowrap="nowrap">
                    ${dataIndex}
                </td>
                <td class="align-center" nowrap="nowrap">
                    <#if dataItem.depType == "1">其他
                    <#elseif dataItem.depType == "R">地区
                    <#elseif dataItem.depType == "C">公司
                    <#elseif dataItem.depType == "D">部门
                    <#elseif dataItem.depType == "G">退队
                    <#else>未知
                    </#if>
                </td>
                <td class="align-center" nowrap="nowrap">
                    ${dataItem.depCode}
                </td>
                <td nowrap="nowrap">
                    <span style="${caption_class}">
                        <#if level gt 0><#list 1..level as i>${separator}</#list></#if>
                        <span>${dataItem.depName}</span>
                    </span>
                </td>
                <td class="align-center layui-hide-xs" >
                    <span>${dataItem.principal}</span>
                </td>
                <td class="align-center layui-hide-xs" >
                    <span>${dataItem.mobil}</span>
                </td>
                <td class="align-center layui-hide-xs" >
                    <span>${dataItem.phone}</span>
                </td>
                <td class="layui-hide-xs">
                    <span>${dataItem.address}</span>
                </td>
                <td class="align-center layui-hide-xs" nowrap="nowrap">
                    <#if dataItem.status?string == "T">
                        <span class="layui-bg-green status-show">启用</span>
                    <#else>
                        <span class="layui-bg-red status-show">禁用</span>
                    </#if>
                </td>
                <td class="align-center">
                    <div class="layui-table-cell">
                         <a class="layui-btn layui-btn-normal layui-btn-xs" href="edit/${dataItem.depId}">
                            <i class="layui-icon layui-icon-edit"></i>编辑
                         </a> 
                         <#if dataItem.upperId != '-1'>
                         <button type="button" class="layui-btn layui-btn-danger layui-btn-xs"
                             onclick="confirmSubmit('确定要删除机构‘${dataItem.depName}’吗?', {guid:'${dataItem.guid}',depId:'${dataItem.depId}',depName:'${dataItem.depName}'},'del')">
                             <i class="layui-icon layui-icon-delete"></i>删除
                         </button>
                         </#if>
                     </div>
                </td>
            </tr>
            </@ctrl.Recursive>
        </tbody>
    </table>
</form>
</@override>
<@override name="page-scripts">
    <script>
        $(function(){
            layui.use(['form','layer', 'jquery'], function(){
                var form=layui.form;
                var layer=layui.layer;
                var $ = layui.jquery;
                $('.js-add').on('click', function(){
                    var guid = $('#guid').val();
                    window.location.href="${contextPath}/admin/department/add/"+guid;
                })
            })
        })
    </script>
</@override>
<@extends name="/layout/basepage.html"/> 
